/**************************************************
 	dOpsys Week-3
 	Nikolas Bram & Dennis Thomasen
 	20104268     & 20103903
 	Linked list implementation for  the
 	consumer-producer exercise
 **************************************************/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>

#include "producer-consumer-list.h"

struct list *l;

void* consumer(void *args){
	int i;
	sleep(5);
	for (i = 0; i < 10; i++) {
		remove_list(l);
	}
}

void* producer(void *args){
	int i;
	for (i = 0; i < 10; i++) {
		char str[64] = "hej";
		add_list(l,new_node_str(str));
		sleep(2);
	}
}

int main(int argc, char *argv[])
{
	l = new_list();
	pthread_t consum;
	pthread_t produc;
	pthread_create(&produc, NULL, producer, NULL);
	pthread_create(&consum, NULL, consumer, NULL);
	pthread_join(consum, NULL);
	pthread_join(produc, NULL);
}
